<template>
	<view class="pageItem">
		<block v-if="language">
			<web-view class="videoItem" :src="'/static/video_h5/index.html#/pages/popular/shortDetail?lang='+language+'&id='+this.id" @message="onPostMessage"></web-view>
		</block>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	export default {
		data() {
			return {
				id : 0,
				language:'',
			}
		},
		onLoad(opt) {
			this.id = opt.id;
			console.log('app shortDetail');
			console.log(this.id);
			this.language = uni.getLocale();
			uni.$on('postMessage', this.onPostMessage);
		},
		mounted() {
			let token =  uni.getStorageSync('token') ? uni.getStorageSync('token') : '';
			let userInfo = uni.getStorageSync('userInfo') || '';
			
			console.log('app_token:'+token)
			const
			     _funName = 'msgFromUni',
			    _data = {token,userInfo};
			this.$nextTick(()=>{
				const currentWebview = this.$scope.$getAppWebview().children()[0];
				currentWebview.evalJS(`${_funName}(${JSON.stringify(_data)})`);
			})
			
		},
		onUnload() {
		    uni.$off('postMessage', this.onPostMessage);
		},
		methods:{
			onPostMessage(event){
				this.backTo();
			}
		}
	}
</script>
<style>
page{
	background: #000000;
}
</style>
<style lang="scss">
.pageItem{
	padding: 0;
	padding-top: var(--status-bar-height);
}
.videoItem{
	width: 100vw;
	height: calc(100vh - var(--status-bar-height));
	position: fixed;
	z-index: 90;
}
</style>
